//
//  BassViewController.m
//  DA_V
//
//  Created by 周季阳 on 15/4/22.
//  Copyright (c) 2015年 zhouhai. All rights reserved.
//

#import "BassViewController.h"
#import "InterFace.h"
#import "UIViewAdditions.h"
#import "InfoViewController.h"
@interface BassViewController ()

@end

@implementation BassViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//传入字符串返回RGB
- (UIColor *) colorWithHexString: (NSString *)color
{
    NSString *cString = [[color stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
    
    // String should be 6 or 8 characters
    if ([cString length] < 6) {
        return [UIColor clearColor];
    }
    
    // strip 0X if it appears
    if ([cString hasPrefix:@"0X"])
        cString = [cString substringFromIndex:2];
    if ([cString hasPrefix:@"#"])
        cString = [cString substringFromIndex:1];
    if ([cString length] != 6)
        return [UIColor clearColor];
    
    // Separate into r, g, b substrings
    NSRange range;
    range.location = 0;
    range.length = 2;
    
    //r
    NSString *rString = [cString substringWithRange:range];
    
    //g
    range.location = 2;
    NSString *gString = [cString substringWithRange:range];
    
    //b
    range.location = 4;
    NSString *bString = [cString substringWithRange:range];
    
    // Scan values
    unsigned int r, g, b;
    [[NSScanner scannerWithString:rString] scanHexInt:&r];
    [[NSScanner scannerWithString:gString] scanHexInt:&g];
    [[NSScanner scannerWithString:bString] scanHexInt:&b];
    
    return [UIColor colorWithRed:((float) r / 255.0f) green:((float) g / 255.0f) blue:((float) b / 255.0f) alpha:1.0f];
    
}
//转化成圆形
-(UIImage*) circleImage:(UIImage*) image withParam:(CGFloat) inset {
    UIGraphicsBeginImageContext(image.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetLineWidth(context, 2);
    CGContextSetStrokeColorWithColor(context, [UIColor clearColor].CGColor);
    CGRect rect = CGRectMake(inset, inset, image.size.width - inset * 2.0f, image.size.height - inset * 2.0f);
    CGContextAddEllipseInRect(context, rect);
    CGContextClip(context);
    
    [image drawInRect:rect];
    CGContextAddEllipseInRect(context, rect);
    CGContextStrokePath(context);
    UIImage *newimg = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newimg;
}
-(void)initNav{
    navView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH*0.2)];
    navView.backgroundColor = [self colorWithHexString:@"#EB2F6C"];
    [self.view addSubview:navView];
    
    navTitle = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH, SCREEN_WIDTH*0.2-20)];
    navTitle.text = @"验证";
    navTitle.textColor = [UIColor whiteColor];
    navTitle.textAlignment = NSTextAlignmentCenter;
    navTitle.font = [UIFont boldSystemFontOfSize:16];
    [navView addSubview:navTitle];
    
    navBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    //[navBtn setTitle:@"返回" forState:UIControlStateNormal];
    navBtn.frame = CGRectMake(-10, 20, 70, 44);
    //navBtn.titleLabel.font = [UIFont systemFontOfSize:14];
//    navBtn.backgroundColor = [UIColor redColor];
    
     [navBtn setImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
//    [navBtn setBackgroundImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
//    [navBtn setBackgroundImage:[UIImage imageNamed:@"fanhui1"] forState:UIControlStateHighlighted];
    [navBtn addTarget:self action:@selector(clickBackBtn) forControlEvents:UIControlEventTouchUpInside];
    //[navBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [navView addSubview:navBtn];
    
    //查看库存_03
    navRightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    //[navBtn setTitle:@"返回" forState:UIControlStateNormal];
    navRightBtn.frame = CGRectMake(SCREEN_WIDTH-43, 5+(SCREEN_WIDTH*0.2-18)/2, 23, 29);
    //navBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    navRightBtn.backgroundColor = [UIColor clearColor];
    [navRightBtn setBackgroundImage:[UIImage imageNamed:@"查看库存_03"] forState:UIControlStateNormal];
    [navRightBtn addTarget:self action:@selector(clickXinRightBtn) forControlEvents:UIControlEventTouchUpInside];
    //[navBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [navView addSubview:navRightBtn];
    
}
-(void)clickBackBtn{
    
}
-(void)clickXinRightBtn{
    InfoViewController *info = [[InfoViewController alloc]init];
    info.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:info animated:YES];
    
}
#pragma mark - 判断字符串是否为空
- (BOOL) isBlankString:(NSString *)string {
    if ((NSNull *)string == nil || (NSNull *)string == NULL || [string isEqualToString:@"<null>"]) {
        return YES;
    }
    if ([(NSNull *)string isKindOfClass:[NSNull class]]) {
        return YES;
    }
    if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) {
        return YES;
    }
    return NO;
}
/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
